package com.dy.drp.service.impl;

import com.dy.drp.dto.SaleCollect;
import com.dy.drp.entity.Salelist;
import com.dy.drp.mapper.SalelistMapper;
import com.dy.drp.service.ISalelistService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dy.drp.util.PageUtil;
import com.dy.drp.util.SelectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dy
 * @since 2022-04-02
 */
@Service
public class SalelistServiceImpl extends ServiceImpl<SalelistMapper, Salelist> implements ISalelistService {
    @Autowired
    private SalelistMapper salelistMapper;

    @Override
    public PageUtil<SaleCollect> selectCollect(SelectUtil selectUtil) {
        PageUtil<SaleCollect> pageUtil = new PageUtil<>();
        pageUtil.setPageNum(selectUtil.getPageNum());
        pageUtil.setPageSize(selectUtil.getPageSize());

        Integer integer = salelistMapper.selectCount().size();
        pageUtil.setCount(integer);
        pageUtil.setTotalPage(integer);

        List<SaleCollect> saleCollects = salelistMapper.selectCollect(selectUtil);
        pageUtil.setList(saleCollects);
        return pageUtil;
    }

    @Override
    public PageUtil<SaleCollect> selectCollectByInfo(SelectUtil selectUtil) {
        PageUtil<SaleCollect> pageUtil = new PageUtil<>();
        pageUtil.setPageNum(selectUtil.getPageNum());
        pageUtil.setPageSize(selectUtil.getPageSize());

        Integer integer = salelistMapper.selectCountByInfo(selectUtil).size();
        pageUtil.setCount(integer);
        pageUtil.setTotalPage(integer);

        List<SaleCollect> saleCollects = salelistMapper.selectCollectByInfo(selectUtil);
        pageUtil.setList(saleCollects);
        return pageUtil;
    }
}
